package br.com.config.shard;

import br.com.model.entidade.Pessoa;
import org.hibernate.shards.ShardId;
import org.hibernate.shards.strategy.selection.ShardSelectionStrategy;

public class ShardSelectionStrategyImpl implements ShardSelectionStrategy {

    @Override
    public ShardId selectShardIdForNewObject(Object obj) {
    if (obj instanceof Pessoa) {
        Pessoa pessoa = (Pessoa) obj;
        int tenantId = pessoa.getTenantId();
        return new ShardId(tenantId);
    }
        throw new IllegalArgumentException();
    }
}